package com.liuguang.gateway.config.quartz.job;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.stereotype.Component;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @ClassName: MyJob
 * @Description：
 * @Author: wanghr
 * Date: 7:10 PM 2020/9/24
 * Version: 1.0
 */
public class MyJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(MyJob.class);

    /**
     * 执行任务
     *
     * @params: [jobExecutionContext]
     * @return: void
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        DateFormat instance = new SimpleDateFormat("现在时间：yyyy-MM-dd hh:mm:ss");
        String date = instance.format(new Date());
        logger.info("开始执行 MyJob，当前时间：{}", date);
    }
}
